package com.project.controller;

import com.project.bean.CutPageBean;
import com.project.bean.RoomBean;
import com.project.service.IRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("room")
public class RoomController {

    @Autowired
    private IRoomService roomService;

    @RequestMapping("findByItem")
    public CutPageBean<RoomBean> findByItem(int pageNO, String address, String state, String info, String type) {
        return roomService.findByItem(pageNO, address, state, info, type);
    }

    @RequestMapping("del")
    public String del(Integer id) {
        boolean flag = roomService.del(id);
        if (flag) {
            return "ok";
        } else {
            return "no";
        }
    }

    @RequestMapping("findById")
    public RoomBean findById(Integer id) {
        return roomService.findByRoomId(id);
    }


    @RequestMapping("add")
    public String add(RoomBean roomBean) {
        roomService.add(roomBean);
        return "ok";
    }

    @RequestMapping("findByGender")
    public List<RoomBean> findByGender(String gender) {
        return roomService.findByGender(gender);
    }

}
